//
//  Blogs.m
//  oschina_song
//
//  Created by song on 16/1/28.
//  Copyright © 2016年 song. All rights reserved.
//

#import "OSCBlogs.h"
#import "NSDate+Util.h"


static NSString * const kID = @"id";
static NSString * const kTitle = @"title";
static NSString * const kBody = @"body";
static NSString * const kCommentCount = @"commentCount";
static NSString * const kAuthor = @"authorname";
static NSString * const kAuthorID = @"authoruid";
static NSString * const kPubDate = @"pubDate";
static NSString * const kDocumentType = @"documentType";



@implementation OSCBlogs



-(instancetype)initWithXML:(ONOXMLElement *)xml
{

    self = [super init];
    if(self)
    {
        _blogID = [[[xml firstChildWithTag:kID] numberValue] longLongValue];
        _author = [[xml firstChildWithTag:kAuthor] stringValue];
        _authorID = [[xml firstChildWithTag:kAuthorID] stringValue];
        _title = [[xml firstChildWithTag:kTitle] stringValue];
        _body = [[xml firstChildWithTag:kBody] stringValue];
        _pubDate =  [NSDate dateFromString:[[xml firstChildWithTag:kPubDate] stringValue]];
        _commentCount = [[[xml firstChildWithTag:kCommentCount] numberValue] longLongValue];
        _documentType = [[[xml firstChildWithTag:kDocumentType] numberValue] longLongValue];
    }
    
    return self;
}

@end
